home *** CD-ROM | disk | FTP | other *** search
- Path: hydro.com!news
- From: Terje Mathisen <Terje.Mathisen@hda.hydro.com>
- Newsgroups: comp.lang.c,comp.os.msdos.programer,comp.os.ms-windows.programmer.misc
- Subject: Re: fastest code
- Date: Sun, 14 Apr 1996 22:34:01 +0200
- Organization: Hydro
- Message-ID: <31716139.262D@hda.hydro.com>
- References: <316112A2.7D37@public.sta.net.cn> <31611AC9.7DE1@wight.hursley.ibm.com> <3162c21a.6084138@204.248.25.97> <31641DE2.31D4@halcyon.com> <31658942.99299605@204.248.25.97> <4kp41m$jhc@news.manawatu.gen.nz>
- NNTP-Posting-Host: 163.34.27.130
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.01 (Win95; I)
-
- Gary Thomas wrote:
- >
- > srwillrd@novia.net (William E. Kempf) wrote:
- >
- > >As an example: if the C code looked like this...
- >
- > >while (condition)
- > >{
- > > a = 10;
- > > // other code that does not change a
- > >}
- >
- > >a good optimizing compiler would move the a = 10 statement before the
- > >loop in the final machine code.
- >
- > How about this sequence:
- >
- > b = 6;
- > a = 5;
- > while (b < 4)
- > {
- > a = 10;
- > // other code that does not affect q
- > }
- >
- > Your "optimizing" compiler would come out of that one with a == 10,
- > when it should be a == 5
-
- No Way!
-
- A good compiler would instead remove the complete while () loop, since it is obvious that it will never
- be executed!
-
- --
- -Terje Mathisen (include std disclaimer) <Terje.Mathisen@hda.hydro.com>
- "almost all programming can be viewed as an exercise in caching"
-